class StockMaterialinout {
  String? id;
  String? documentcode;
  String? materialcode;
  String? materialname;
  String? model;
  String? batchnumber;
  String? purchaseunit;
  String? quantity;
  String? suppliercode;
  String? suppliername;
  String? operator;
  String? operatdate;
  String? inoutidentification;
  String? warehousename;
  String? storagelocationname;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? readflag;
  String? workshopId;
  String? locationDestId;
  String? locationDestName;

  StockMaterialinout({
    this.id,
    this.documentcode,
    this.materialcode,
    this.materialname,
    this.model,
    this.batchnumber,
    this.purchaseunit,
    this.quantity,
    this.suppliercode,
    this.suppliername,
    this.operator,
    this.operatdate,
    this.inoutidentification,
    this.warehousename,
    this.storagelocationname,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.readflag,
    this.workshopId,
    this.locationDestId,
    this.locationDestName,
  });

  StockMaterialinout copyWith({
    String? id,
    String? documentcode,
    String? materialcode,
    String? materialname,
    String? model,
    String? batchnumber,
    String? purchaseunit,
    String? quantity,
    String? suppliercode,
    String? suppliername,
    String? operator,
    String? operatdate,
    String? inoutidentification,
    String? warehousename,
    String? storagelocationname,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
    String? readflag,
  }) {
    return new StockMaterialinout(
      id: id ?? this.id,
      documentcode: documentcode ?? this.documentcode,
      materialcode: materialcode ?? this.materialcode,
      materialname: materialname ?? this.materialname,
      model: model ?? this.model,
      batchnumber: batchnumber ?? this.batchnumber,
      purchaseunit: purchaseunit ?? this.purchaseunit,
      quantity: quantity ?? this.quantity,
      suppliercode: suppliercode ?? this.suppliercode,
      suppliername: suppliername ?? this.suppliername,
      operator: operator ?? this.operator,
      operatdate: operatdate ?? this.operatdate,
      inoutidentification: inoutidentification ?? this.inoutidentification,
      warehousename: warehousename ?? this.warehousename,
      storagelocationname: storagelocationname ?? this.storagelocationname,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      readflag: readflag ?? this.readflag,
    );
  }

  @override
  String toString() {
    return '''StockMaterialinout{
      id: id,
      documentcode: documentcode,
      materialcode: materialcode,
      materialname: materialname,
      model: model,
      batchnumber: batchnumber,
      purchaseunit: purchaseunit,
      quantity: quantity,
      suppliercode: suppliercode,
      suppliername: suppliername,
      operator: operator,
      operatdate: operatdate,
      inoutidentification: inoutidentification,
      warehousename: warehousename,
      storagelocationname: storagelocationname,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
      readflag: readflag,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is StockMaterialinout &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          documentcode == other.documentcode &&
          materialcode == other.materialcode &&
          materialname == other.materialname &&
          model == other.model &&
          batchnumber == other.batchnumber &&
          purchaseunit == other.purchaseunit &&
          quantity == other.quantity &&
          suppliercode == other.suppliercode &&
          suppliername == other.suppliername &&
          operator == other.operator &&
          operatdate == other.operatdate &&
          inoutidentification == other.inoutidentification &&
          warehousename == other.warehousename &&
          storagelocationname == other.storagelocationname &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate &&
          readflag == other.readflag);

  factory StockMaterialinout.fromMap(Map<String, dynamic> map) {
    return new StockMaterialinout(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      documentcode: map['documentcode'] != false
          ? map['documentcode'].toString() as String?
          : "",
      materialcode: map['materialcode'] != false
          ? map['materialcode'].toString() as String?
          : "",
      materialname: map['materialname'] != false
          ? map['materialname'].toString() as String?
          : "",
      model: map['model'] != false ? map['model'].toString() as String? : "",
      batchnumber: map['batchnumber'] != false
          ? map['batchnumber'].toString() as String?
          : "",
      purchaseunit: map['purchaseunit'] != false
          ? map['purchaseunit'].toString() as String?
          : "",
      quantity:
          map['quantity'] != false ? map['quantity'].toString() as String? : "",
      suppliercode: map['suppliercode'] != false
          ? map['suppliercode'].toString() as String?
          : "",
      suppliername: map['suppliername'] != false
          ? map['suppliername'].toString() as String?
          : "",
      operator:
          map['operator'] != false ? map['operator'].toString() as String? : "",
      operatdate: map['operatdate'] != false
          ? map['operatdate'].toString() as String?
          : "",
      inoutidentification: map['inoutidentification'] != false
          ? map['inoutidentification'].toString() as String?
          : "",
      warehousename: map['warehousename'] != false
          ? map['warehousename'].toString() as String?
          : "",
      storagelocationname: map['storagelocationname'] != false
          ? map['storagelocationname'].toString() as String?
          : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
      readflag:
          map['readflag'] != false ? map['readflag'].toString() as String? : "",
      locationDestId: (map['location_dest_id']!=false&&map['location_dest_id']!=null)?map['location_dest_id'][0].toString():"",
      locationDestName: (map['location_dest_id']!=false&&map['location_dest_id']!=null)?map['location_dest_id'][1].toString():""
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'documentcode': this.documentcode,
      'materialcode': this.materialcode,
      'materialname': this.materialname,
      'model': this.model,
      'batchnumber': this.batchnumber,
      'purchaseunit': this.purchaseunit,
      'quantity': this.quantity,
      'suppliercode': this.suppliercode,
      'suppliername': this.suppliername,
      'operator': this.operator,
      'operatdate': this.operatdate,
      'inoutidentification': this.inoutidentification,
      'warehousename': this.warehousename,
      'storagelocationname': this.storagelocationname,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'readflag': this.readflag,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [

      if (this.readflag != null && this.readflag != '')
        ['readflag', '=', int.parse(this.readflag!)],
      if (this.documentcode != null && this.documentcode != '')
        ['documentcode', '=', this.documentcode],
      if (this.materialcode != null && this.materialcode != '')
        ['materialcode', 'like', '%${this.materialcode}%'],
      if (this.materialname != null && this.materialname != '')
        ['materialname', 'like', '%${this.materialname}%'],
    ] as List;
    if (list.length == 0) {
      list.add(['id', '!=', null]);
    }
    // ignore: unnecessary_cast
    return list;
  }

  List toWorkshopMaterialDomainList() {
    List list = [
      if (this.documentcode != null && this.documentcode != '')
        ['document', '=', this.documentcode], // 入库单号
      if (this.materialname != null && this.materialname != '')
        ['name', '=', this.materialname], // 物料名称
      if (this.materialcode != null && this.materialcode != '')
        ['code', '=', this.materialcode], // 物料编码
      if (this.locationDestId != null && this.locationDestId != '')
        ['location&', '=', int.parse(this.locationDestId!)],
      // if (this.workshopId != null && this.workshopId != '')
      //   ['plant&', '=', int]], // 车间
    ] as List;
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'documentcode': this.documentcode,
      'materialcode': this.materialcode,
      'materialname': this.materialname,
      'model': this.model,
      'batchnumber': this.batchnumber,
      'purchaseunit': this.purchaseunit,
      'quantity': this.quantity,
      'suppliercode': this.suppliercode,
      'suppliername': this.suppliername,
      'operator': this.operator,
      'operatdate': this.operatdate,
      'inoutidentification': this.inoutidentification,
      'warehousename': this.warehousename,
      'storagelocationname': this.storagelocationname,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'readflag': this.readflag,
    } as Map<String, dynamic>;
  }


//</editor-fold>

}